<template>
    <div class="common-layout">
      <el-container>
        <el-header style="background-color:#409EFF">东软云医院HIS系统</el-header>
        <el-container>
          <el-aside width="200px">
            <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
      >
        <el-sub-menu v-for="(item,i) in menuList" :index="i">
          <template #title>
            <el-icon><Wallet /></el-icon>
            <span>{{ item.name }}</span>
          </template> 
          <template v-for="(menuItem,index) in item.children" >
            <!-- <el-menu-item @click="goPage('/home/'+item.path+'/'+menuItem.path)"><RouterLink :to="'/home/'+item.path+'/'+menuItem.path">{{ menuItem.name }}</RouterLink></el-menu-item> -->
            <el-menu-item @click="goPage('/home/'+item.path+'/'+menuItem.path)">{{ menuItem.name }}</el-menu-item>
          </template>
        
        </el-sub-menu>
      </el-menu>
          </el-aside>
          <el-main>
            <RouterView></RouterView>
          </el-main>
        </el-container>
      </el-container>
    </div>
  </template>

<script setup>
import {
  Menu as IconMenu,
  Wallet,
} from '@element-plus/icons-vue'
import {useRouter} from 'vue-router'
import {routes} from '@/router/index.js'
const menuList=routes[0].children;
const router = useRouter();
const goPage = (url)=>{
  router.push(url)
}


const handleOpen = (key, keyPath) => {
  console.log(key, keyPath)
}
const handleClose = (key, keyPath) => {
  console.log(key, keyPath)
}
</script>